#!/usr/bin/env python3
import sys
import re
from dataclasses import dataclass

@dataclass(order=True)
class Vec:
    x: int
    y: int

    def __str__(self):
        return f'({self.x}, {self.y})'

x1, x2, y1, y2 = [int(group) for group in re.match(r'^target area: x=(-?[0-9]+)..(-?[0-9]+), y=(-?[0-9]+)..(-?[0-9]+)$', input()).groups()]

print(x1, x2, y1, y2)

def within(p, a, b):
    return p >= min(a, b) and p <= max(a, b)

n = -1
y_global_max = -sys.maxsize
v0_global_max = None
for k in range(-x2 if x2 >= 0 else x2, x2 if x2 >= 0 else -x2):
    for l in range(-500, 500):
        n += 1
        p0 = Vec(0, 0)
        p = Vec(p0.x, p0.y)
        v0 = Vec(k, l)
        v = Vec(v0.x, v0.y)
        y_local_max = -sys.maxsize

        if p0.y + v0.y < p0.y and y_global_max > 0:
            continue

        #print(f'attempt #{n} (v0 = {v0})')
        while not (within(p.x, x1, x2) and within(p.y, y1, y2)) and p.y > y2:
            if p.y > y_local_max: y_local_max = p.y
            p.x = p.x + v.x
            v.x += 1 if v.x < 0 else -1 if v.x > 0 else 0
            p.y = p.y + v.y
            v.y -= 1
            if p.x > x2 and v.x >= 0:
                break
            if p.x < x1 and v.x <= 0:
                break
            #print(f'throw   #{n} p = {p} (v = {v})')

        if within(p.x, x1, x2) and within(p.y, y1, y2):
            print(f'success @ attempt #{n} with v0 = {v0}, probe at p = {p} ([{x1}, {x2}], [{y1}, {y2}], local y max = {y_local_max})')
            if y_local_max > y_global_max:
                print(f'new local best {y_local_max} with v0 = {v0} (previous {y_global_max})')
                y_global_max = y_local_max
                v0_global_max = Vec(v0.x, v0.y)

print(f'global max of {y_global_max} with initial velocity v0 = {v0_global_max}')